package com.shoeshopping.action.zx;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.shoeshopping.formbean.zx.UserAdminForm;
import com.shoeshopping.service.zx.GoodsAdminService;
import com.shoeshopping.service.zx.UserAdminService;
import com.shoeshopping.utils.zx.EasyUIResult;
import com.shoeshopping.utils.zx.JsonUtil;
import com.shoeshopping.utils.zx.Result;
import com.shoeshopping.vo.zx.VoUserAdminWithPassword;

@Controller("userAdminAction")
@Scope("prototype")
public class UserAdminAction extends ActionSupport implements ModelDriven<UserAdminForm>{
	
	UserAdminForm dataform = new UserAdminForm();
	
	@Resource
	UserAdminService userAdminService;
	
	VoUserAdminWithPassword voUserAdminWithPassword;
	

	public void list(){
		EasyUIResult result = null;
		try{
			result = userAdminService.list(dataform);
		} finally{
			JsonUtil.output(result);
		}
	} 
	
	public void listAddress(){
		EasyUIResult result = null;
		try{
			result = userAdminService.listAddress(dataform);
		} finally{
			JsonUtil.output(result);
		}
	}
	
	public void delete(){
		userAdminService.delete(dataform);
		JsonUtil.output(Result.success());
	}
	
	public String add(){
		if(userAdminService.add(dataform)){
			return Result.SUCCESS;
		}
		return Result.ERROR;
	}
	
	public String edit(){
		voUserAdminWithPassword  = userAdminService.edit(dataform);
		if(voUserAdminWithPassword != null){
			return Result.EDIT;
		}
		return Result.ERROR;
	}
	
	@Override
	public UserAdminForm getModel() {
		return dataform;
	}
	public VoUserAdminWithPassword getVoUserAdminWithPassword() {
		return voUserAdminWithPassword;
	}

	public void setVoUserAdminWithPassword(
			VoUserAdminWithPassword voUserAdminWithPassword) {
		this.voUserAdminWithPassword = voUserAdminWithPassword;
	}

}
